<template>
  <div class="login-bg">
    <input type="text" placeholder="账号" v-model="username" />
    <input type="password" placeholder="密码" v-model="password" />
    <div class="submit-box" @click="login()">登录</div>
  </div>
</template>
<script>
import api from "@/data/api/index.js";

import Vue from 'vue';
import { Toast } from 'vant';
Vue.use(Toast);
export default {
  data (){
    return {
      username: "16718",
      password: "beone_123"
    }
  },
  created() {

  },
  methods: {
    // 用户登录
    login() {

      if(this.username == "" ){
        Toast("请输入账号")
        return
      }

      if(this.password == ""){
        Toast("请输入密码")
        return
      }

      let params = { username: this.username, password: this.password };
        api.userLogin(params).then((res) => {
          if (res.code == "true") {
            this.$router.replace('/')
          } else {
            Toast(res.msg)
          }
        });
    },
  },
};
</script>
<style lang="scss" scoped>
.login-bg {
  width: 100%;
  height: 100vh;
  overflow: hidden;
  padding-top: 10rem;
  .login-img {
    display: block;
    width: 60%;
    margin: 0 auto;
    margin-top: 4rem;
    margin-bottom: 3rem;
  }
  input {
    display: block;
    width: 80%;
    margin: 0 auto;
    height: 2.7rem;
    margin-bottom: 1rem;
    border: 1px solid #999;
    padding-left: 5%;
    box-sizing: border-box;
  }
  .input-box {
    width: 80%;
    margin: 0 auto;
    display: flex;
    .img-box {
      width: 35%;
      height: 2.7rem;
      border: 1px solid #ccc;
    }
  }
  .submit-box {
    width: 80%;
    height: 2.8rem;
    background: #c9161e;
    color: #fff;
    line-height: 2.8rem;
    text-align: center;
    margin: 0 auto;
    margin-top: 2rem;
  }
}
</style>
